﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Swagger</title>
    <link rel="stylesheet" type="text/css" href="./swagger-ui.css">
</head>
<body>
    <div id="swagger-ui"></div>
</body>
</html>

<script src="swagger-ui-bundle.js"></script>
<script src="swagger-ui-standalone-preset.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/3.0.1/js.cookie.min.js"></script>
<script>
    window.onload = function () {
        var configObject = JSON.parse('%(ConfigObject)');

        const cookie = Cookies.get('access-token');

        if (!cookie) {
            window.location.href = '/home/index';
        }

        // Apply mandatory parameters
        configObject.dom_id = "#swagger-ui";
        configObject.presets = [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset];
        configObject.layout = "StandaloneLayout";
        //configObject.requestInterceptor = function (request) {


        //    request.headers['Authorization'] = 'Bearer ' + cookieValue;
        //    return request;
        //};

        if (!configObject.hasOwnProperty("oauth2RedirectUrl")) {
            configObject.oauth2RedirectUrl = window.location + "oauth2-redirect.html"; // use the built-in default
        }

        configObject.plugins = [
            function (system) {
                return {
                    components: {
                        authorizeBtn: function () {
                            return null;
                        }
                    }
                }
            }
        ];

        // Build a system
        SwaggerUIBundle(configObject);
    }

</script>
